# Maintainer: Giancarlo Razzolini <grazzolini@archlinux.org>
# Maintainer: Morten Linderud <foxboron@archlinux.org>
# Contributor: Dave Reisner <dreisner@archlinux.org>
# Contributor: Thomas Bächler <thomas@archlinux.org>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - swap zstd for gzip in depends, remove gzip optdepend
#  - patch to revert back to gzip for default compression
#  - patch for gzip kernel image support (https://github.com/archlinux/mkinitcpio/pull/86)

pkgname=mkinitcpio
pkgver=39.2
pkgrel=2
pkgdesc="Modular initramfs image creation utility"
arch=('any')
url='https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio'
license=('GPL-2.0-only')
depends=('awk' 'mkinitcpio-busybox>=1.19.4-2' 'kmod' 'util-linux>=2.23' 'libarchive' 'coreutils'
         'bash' 'binutils' 'diffutils' 'findutils' 'grep' 'filesystem>=2011.10-1' 'gzip' 'systemd')
checkdepends=('bats' 'bats-assert' 'lzop')
makedepends=('asciidoc')
checkdepends=('bats' 'bats-assert' 'lzop')
optdepends=('xz: Use lzma or xz compression for the initramfs image'
            'bzip2: Use bzip2 compression for the initramfs image'
            'lzop: Use lzo compression for the initramfs image'
            'lz4: Use lz4 compression for the initramfs image'
            'mkinitcpio-nfs-utils: Support for root filesystem on NFS')
provides=('initramfs')
backup=('etc/mkinitcpio.conf')
source=("https://sources.archlinux.org/other/$pkgname/$pkgname-$pkgver.tar.xz"{,.sig}
        '0001-trigger.patch'
        '0001-use-gzip-for-compression-by-default.patch'
        '0002-functions-handle-gzip-compressed-kernels-in-kver_gen.patch'
        '0003-check-for-ALARM-kernels-in-run_post_hooks.patch')
sha512sums=('e4ba9fe901da56bb116510ec0c6abeba5153e57d9545baccbc466932951b7f324aa75ef7cc3de87f966456b0365b17552f367411d62585d500e88dc5c815058b'
            'SKIP'
            'b21e3961294e80bedd89a7e332ab11fc3b83eebfaf58d8f658e30f7d9caf2f84f4934224173c70f111932de8538fa327f5f6bfe9576b11bcbaf84d2d5ad8e85d'
            '829b963c5e32f84fcf2abfae2b9df2b7834e6cc0d38ffb14665418d070a2b18dd3471b9d23b5251da3d1c138f73b7ec861715228104df6077f21b1f62101dd54'
            'f60bb707ca0ff7912a4745cf5df04a517ed96c5a8376c30abb68941b947dea3645af93ad7d5de21747bffe9f9d72ef1598bbc8db903110efc5ceef71991663a0'
            '20b10e783f7bb35a3840ef208b44e22ff2fb57cb5bb4cebff037fbedb8949e907b5e0498561efb99642139201640bceeeedb86ffe97ec3380429ae7c7f71b23c')
b2sums=('7bd6bf491dd8b23d83e42834566375736cf8868d5120c7e24f4c8923eb03a64864cdda51d6a6f41373db88c29905535e4c8aa4bde172955bc7529e6b3ffc252c'
        'SKIP'
        '3b8e08d56e209ad11827d65595ab245bb680e72fb81139ba946e7610d16214c2a9022f1a1794e6797ef07fb0a43c5239167729225daf89396a8920f39f75e34b'
        '514e092c75cd686f50791dad15ebd99e75ead64770d3b070f856fce2eab345b4bd8b4405410b3ff6b451a5a22d0afbf7c49853ccd23d9b02fa4797524cd7a07f'
        '414cf87d3d3f56e1cdb39f1a5e33eb93b8ea298ab292f26b45314ccdcb706ebe2b8f0183a61c01537866b199fd6a970f0f1d04a705203354b52719f177250869'
        'a44f5b0a51876244cc2aef566925b2c17bf9ddf39ade5042d98ca216ae90e1da8945bf6bd3e4f1d96977f5f5e8c00e41f74728f3e9d8d873305938ab3d5b59b7')
validpgpkeys=('ECCAC84C1BA08A6CC8E63FBBF22FB1D78A77AEAB'    # Giancarlo Razzolini
              'C100346676634E80C940FB9E9C02FF419FECBE16')   # Morten Linderud

prepare() {
  cd "$pkgname-$pkgver"
  patch -Np1 < ../0001-trigger.patch
  patch -p1 -i ../0001-use-gzip-for-compression-by-default.patch
  patch -p1 -i ../0002-functions-handle-gzip-compressed-kernels-in-kver_gen.patch
  patch -p1 -i ../0003-check-for-ALARM-kernels-in-run_post_hooks.patch
}

check() {
  make -C "$pkgname-$pkgver" check
}

package() {
  make -C "$pkgname-$pkgver" DESTDIR="$pkgdir" install
}
